import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  build: {
    // 确保生产环境构建时保持源码结构
    minify: 'terser',
    terserOptions: {
      compress: {
        // 保持函数名和变量名，避免压缩导致的问题
        keep_fnames: true,
        keep_classnames: true
      }
    }
  },
  // 确保开发服务器正确处理路由
  server: {
    historyApiFallback: true
  }
})
